#pragma once

#include "Part.h"
#include "Common/AdventureDefine.h"

class AdventurePart : public Part
{
public:
	AdventurePart();
	virtual ~AdventurePart();
public:
	virtual bool		Init(Creature *pMaster, uint32_t partType, CharacterDBInfo* pCharacterDB = nullptr);
	virtual bool		UnInit();
	virtual bool		OnMsgHandle(uint32_t cmd, const char* data, uint32_t len);
	virtual void		OnExecute(uint16_t nEventID, uint64_t nSrcID, uint8_t bySrcType, void *pContext, int32_t nLen);
	virtual void		OnTimer(uint32_t nTimerID){}
	virtual bool		SaveDB(CharacterDBInfo& characterDB);
	virtual void		Update(uint64_t tick){}
public:
	//共享杀怪计数
	void ShareKillMonsCount(uint32_t monsId);
	//客户端行为
	bool OnClientAction(int32_t actionType, uint32_t actionVal);
private:
	/////////////////////////////////  奇遇事件 /////////////////////////////////////////
	//进入区域
	bool EnterArea(uint32_t areaId);
	//离开区域
	bool LeaveArea(uint32_t areaId);
	//进入副本
	void EnterDup(uint32_t dupId);
	//使用物品
	void UseItem(uint32_t itemId);
	//获得物品
	void AddItem(uint32_t itemId);
	//NPC交谈
	bool NpcTalk(uint32_t npcId);
	//转换阵营
	void CampChange();
	//完成采集 sonType:采集子类型
	void Collect(int32_t sonType);
	//完成制造
	void Make(int32_t sonType);
	//完成制造道具
	void MakeItem(int32_t sonType);
	//击杀怪物
	void KillMons(uint32_t monsId);
	//怪物计数
	void MonsDieCount(uint32_t monsId);
	//玩家复活
	void Relive();
	//世界喊话
	void WorldChat();
	//发送邮件
	void SendMail();
	//完成洗点
	void ClearPoint();
	//精炼
	void Refine();
	//星盘传送
	void PandosTrans();
	//激活坐骑
	void ActiveHorse(uint32_t horseId);
	//参加活动
	void AttendActivity(uint32_t activityId);
	//完成活动
	void FinishActivity(uint32_t activityId);
	//参加竞选
	void CampSelect();
	//挖宝
	void Treasure();
	//充值
	void Charge();
private:

	//////////////////////////////////// 系统事件 //////////////////////////////////////
	//怪物死亡
	void OnMonsDieEvent(DieEvent &dieEvent);
	//复活
	void OnReliveEvent(ReliveEvent &reliveEvent);
	//精炼
	void OnRefineEvent(EquipRefineEvent &refineEvent);
	//挖宝
	void OnTreasureEvent(TreasureEvent &treasureEvent);
	//进入副本
	void OnEnterDupEvent(EnterDupEvent &enterEvent);
	//使用物品
	void OnItemUseEvent(ItemUseEvent &useEvent);
	//物品改变
	void OnItemChangeEvent(ItemChangeEvent &changeEvent);
	//转换阵营
	void OnCampChangeEvent(ChangeCampEvent &changeEvent);
	//首领竞选
	void OnCampSelectEvent(CampElectionEvent &selEvent);
	//采集成功
	void OnCollectSucessEvent(CollectOperateEvent &sucessEvent);
	//制造
	void OnMakeEvent(ForgeEquipEvent &forgeEvent);
	//制造道具
	void OnMakeItemEvent(MakeOperateEvent &operateEvent);
	//充值
	void OnChargeEvent(PayEvent &payEvent);
	//参加活动
	void OnAttendActEvent(AttendActEvent &attendEvent);
	//完成活动
	void OnFinishActEvent(FinishActEvent &finishEvent);
	//切换场景
	void OnEnterSceneEvent(EnterSceneEvent &enterEvent);
	//洗点
	void OnClearPointEvent(ClearPointEvent &clearEvnet);
	//世界聊天
	void OnWorldChatEvent(ChatWorldEvent &chatEvent);
public:
	//奇遇信息
	void Info(const char *data, uint32_t len);
	//通知奇遇信息
	void NotifyInfo();
	//接取奇遇任务
	void Accept(const char *data, uint32_t len);
private:
	//设置奇遇信息
	void SetAdventureProto(AdventureProto &proto);
	//检查奇遇时间
	void CheckAdventureTime();
	//奇遇剩余时间
	int32_t AdventureLeftSec();
	//检查触发奇遇
	bool CheckTriggerAdventure(ActionCfgInfo &action);
private:
	uint32_t m_adventureId;	//可接取的奇遇ID
	uint64_t m_adventureTime;		//奇遇结束时间
};
